<template>
  <div class="dashboard-editor-container">
    <!-- <el-card class="cardbox" /> -->
    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="18">
        <el-card class="cardbox1" :style="{background:$store.getters.theme}">
          <div class="cbox1">
            <p class="p1">👏欢迎回来，{{ name }}</p>
            <p class="p2">欢迎使用{{ platformName }}，感谢相遇！本平台是一个可以支持企业各业务系统或产品快速开发实现的平台，其核心理念是提高开发人员开发效率，降低企业信息化系统的开发成本。平台封装了大量技术开发包、技术应用组件、业务场景实现。希望能帮助到你！</p>
            <el-button style="background:#fff;" class="more" @click="handleHelpClick">了解更多</el-button>
          </div>
          <div class="cbox2">
            <el-image :src="require('@/framework/assets/welcomePicture.png')" fit="fill" />
          </div>
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="6"
              style="padding-left:0" class="cardcss">
        <el-card style="height:312px;margin-top:16px">
          <p class="title" style="margin:0 0 16px">常用功能</p>
          <div class="cardbox2">
            <div v-for="(item,index) in allList" :key="index" :style="{'--themecolor':themeActive}"
                 class="cardbox2-item" @click="goto(item.path)">
              <p> <i :class="item.icon" /></p>
              <!-- <svg-icon :icon-name="item.icon" /> -->
              <span>{{ item.title }}</span>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
    <el-card class="cardbox">
      <p class="title">数据统计分析</p>
      <PanelGroup @handleSetLineChartData="handleSetLineChartData" />
      <!-- <el-row>
        <NoticeList />
      </el-row> -->
      <el-row>
        <p class="title">系统访问趋势 <span class="title2">(近半年)</span> </p>
        <LineChart :chart-data="lineChartData" />
      </el-row>
    </el-card>
    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="8">
        <el-card class="chart-wrapper">
          <PieChart />
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8"
              style="padding:0">
        <el-card class="chart-wrapper">
          <!-- <raddar-chart /> -->
          <PieRoleChart />

        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <el-card class="chart-wrapper">
          <BarChart />
        </el-card>
      </el-col>
    </el-row>

    <!--
    <el-row :gutter="8">
      <el-col :xs="{span: 24}" :sm="{span: 24}" :md="{span: 24}" :lg="{span: 12}" :xl="{span: 12}" style="padding-right:8px;margin-bottom:30px;">
        <transaction-table />
      </el-col>
      <el-col :xs="{span: 24}" :sm="{span: 12}" :md="{span: 12}" :lg="{span: 6}" :xl="{span: 6}" style="margin-bottom:30px;">
        <todo-list />
      </el-col>
      <el-col :xs="{span: 24}" :sm="{span: 12}" :md="{span: 12}" :lg="{span: 6}" :xl="{span: 6}" style="margin-bottom:30px;">
        <box-card />
      </el-col>
    </el-row> -->
  </div>
</template>

<script>
import PanelGroup from './components/PanelGroup'
// import NoticeList from './components/NoticeList'
import LineChart from './components/LineChart'
// import RaddarChart from './components/RaddarChart'
import PieChart from './components/PieChart'
import PieRoleChart from './components/PieRoleChart'

import BarChart from './components/BarChart'
// import TransactionTable from './components/TransactionTable'
// import TodoList from './components/TodoList'
// import BoxCard from './components/BoxCard'

const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160],
    actualData: [32, 22, 31, 54, 42, 40]
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130]
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [122, 82, 91, 154, 162, 140, 130]
  }
}
export default {
  name: 'DashboardAdmin',
  components: {
    PanelGroup,
    LineChart,
    // RaddarChart,
    // NoticeList,
    PieChart,
    PieRoleChart,
    BarChart
    // TransactionTable,
    // TodoList,
    // BoxCard
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis,
      list: [
        { icon: 'el-icon-user', name: '用户管理' },
        { icon: 'el-icon-files', name: '组织管理' },
        { icon: 'el-icon-mouse', name: '职位管理' },
        { icon: 'el-icon-thumb', name: '角色管理' },
        { icon: 'el-icon-tickets', name: '菜单管理' },
        { icon: 'el-icon-message', name: '通知发布' },
        { icon: 'el-icon-reading', name: '查看日志' },
        { icon: 'el-icon-set-up', name: '在线调试' }

      ],
      allList: []
    }
  },

  computed: {
    name() {
      return this.$store.state.user.name
    },
    platformName() {
      return this.$store.state.settings.platformName
    },
    platformLogo() {
      return this.$store.state.settings.platformLogo
    },
    themeActive() {
      return this.$store.state.settings.theme
    }
  },
  created() {
    this.getList([])
  },
  methods: {
    handleHelpClick() {
      window.open(process.env.VUE_APP_DEV_DOC)
    },
    handleSetLineChartData(type) {
      // this.lineChartData = lineChartData[type]
    },
    getList(data) {
      (data || []).map((item) => {
        if (item.children && item.children.length) {
          this.getList(item.children)
        } else {
          item.shortcut && this.allList.push(item)
        }
        return null
      })
    },
    goto(path) {
      if (path.indexOf('http') !== -1) {
        window.open(path, '_blank')
      } else {
        this.$router.push(path)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  flex: 1;
  padding: 0 16px;
  background-color: rgb(240, 242, 245);
  position: relative;
  .cardbox1{
    margin-top: 16px;
    height: 312px;
      position: relative;
    .el-card__body{
      display: flex;
      // padding: 20px!important;
      .cbox1{
        width: 80%;
        margin-left: 20px;
        z-index: 2;
        // .more{
        //   width: 136px;
        //   height: 56px;
        //   background: #FFFFFF;
        //   box-shadow: 0px 4px 16px 0px rgba(0,0,0,0.2509);
        //   border-radius: 8px 8px 8px 8px;
        //   font-size: 14px;
        //   font-weight: bold;
        // }
      }
      .cbox2{
        position: absolute;
        bottom: 20px;
        right: 20px;
        z-index: 1;
        margin-left: 20px;
      }
      p{
        font-size: 18px;
        font-family: HarmonyOS Sans SC-Medium, HarmonyOS Sans SC;
        font-weight: 500;
        color: #FFFFFF;
        line-height: 24px;
      }
      .p2{
        font-size: 14px;
        line-height: 22px;
        margin: 24px 0 ;
      }
    }
  }
  .cardbox2{
    display: flex;
    // align-items: center;
    flex-wrap: wrap;
    .cardbox2-item{
      width: 23%;
      // height: 64px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-around;
      cursor: pointer;
      margin:0 5% 24px;
      p{
        width: 32px;
        height: 32px;
        background: #F7F8FA;
        border-radius: 6px 6px 6px 6px;
        line-height: 32px;
        text-align: center;
        margin: 0 0 10px;
      }
      span{
        font-size: 12px;
        font-weight: 400;
        color: #2E394E;
        line-height: 20px;
      }
    }
    .cardbox2-item:hover i{
      color: var(--themecolor);
    }
    .cardbox2-item:hover span{
      color: var(--themecolor);
    }
  }

  .cardbox{
    margin-top: 16px;
  }
  .title {
      font-size: 16px;
      font-weight: 500;
      color: #131314;
      line-height: 24px;
      .title2{
        font-size: 13px;
        font-weight: 400;
        color: #8F9299;
        line-height: 22px;
      }
    }
  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }

  .chart-wrapper {
    background: #fff;
    // padding: 16px 16px 0;
    margin-bottom: 16px;
    margin-top: 16px;
  }
}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
  .cardcss{
    padding:0!important;
  }

}
@media (max-width:550px) {
  .cbox2{
        display: none;
      }
}
</style>
<style >
.cardbox1 .el-card__body{
  display: flex;
  align-items: flex-start;
}
</style>
